package com.neusoft.elmboot.controller;

import java.math.BigDecimal;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.elmboot.po.VirtualWallet;
import com.neusoft.elmboot.service.VirtualWalletService;

@RestController
@RequestMapping("/WalletController")
public class WalletController {
	
	@Autowired
	private VirtualWalletService walletService;
	
	@RequestMapping("/getWallet")
	public VirtualWallet getWallet(String userId) {
		return walletService.getWallet(userId);
	}
	
	@RequestMapping("/debit")
	public void debit(String userId, BigDecimal amount)
	{
		 walletService.debit(userId, amount);
	}
	
	@RequestMapping("/credit")
	public void credit(String userId, BigDecimal amount) {
		 walletService.credit(userId, amount);
	}
	
	@RequestMapping("/updateBalance")
	public void  updateBalance(String userId, BigDecimal amount) {
		 walletService.updateBalance(userId, amount);
	}
	
	@RequestMapping("/transaction")
	public void transaction(String inId,String outId,BigDecimal amount) {
		 walletService.transaction(inId, outId, amount);
	}
	@RequestMapping("/createWallet")
	public void createWallet(String userId,BigDecimal balance) {
		walletService.createWallet( userId,  balance);
	}
}
